package com.abc.robot01.fragment

import android.app.Activity
import android.content.Context
import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.abc.robot01.R
import com.abc.robot01.databinding.FragmentSecondBinding

/**
 * A simple [Fragment] subclass as the second destination in the navigation.
 */
class SecondFragment : Fragment() {

    val TAG="SecondFragment"

    private var _binding: FragmentSecondBinding? = null

    // This property is only valid between onCreateView and
    // onDestroyView.
    private val binding get() = _binding!!

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        _binding = FragmentSecondBinding.inflate(inflater, container, false)
        return binding.root

    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

//        binding.buttonSecond.setOnClickListener {
//            val fragmentManager = getFragmentManager();
//            fragmentManager?.let {
//                val fragmentTransaction = it.beginTransaction()
//                fragmentTransaction.replace(R.id.fragment_container, a, "1")
//                fragmentTransaction.commit()
//            }
////            findNavController().navigate(R.id.action_SecondFragment_to_FirstFragment)
//        }
    }

    override fun onDestroyView() {
        super.onDestroyView()
        _binding = null
    }

    override fun onResume() {
        super.onResume()
        Log.e(TAG,"onResume");
    }

    override fun onStart() {
        super.onStart()
        Log.e(TAG,"onStart");
    }

    override fun onPause() {
        super.onPause()
        Log.e(TAG,"onPause");
    }

    override fun onStop() {
        super.onStop()
        Log.e(TAG,"onStop");
    }

    override fun onDestroy() {
        super.onDestroy()
        Log.e(TAG,"onDestroy");
    }

    override fun onDetach() {
        super.onDetach()
        Log.e(TAG,"onDetach");
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        Log.e(TAG,"onCreate");
    }

    override fun onAttach(activity: Activity) {
        super.onAttach(activity)
        Log.e(TAG,"onAttach activity");
    }

    override fun onAttach(context: Context) {
        super.onAttach(context)
        Log.e(TAG,"onAttach Context");
    }
}